package com.xiaoshuidi.cloud.module.bpm.convert.reserveticket;

import cn.hutool.core.date.LocalDateTimeUtil;
import com.xiaoshuidi.cloud.module.bpm.controller.admin.reserveticket.vo.ReserveTicketExcelVO;
import com.xiaoshuidi.cloud.module.bpm.controller.admin.reserveticket.vo.ReserveTicketRespVO;
import com.xiaoshuidi.cloud.module.bpm.enums.CustomeSourceEnum;
import com.xiaoshuidi.cloud.module.bpm.enums.SexEnum;

import java.util.ArrayList;
import java.util.List;

public class MyReserveTicketConvert {
    public static List<ReserveTicketExcelVO> convert(List<ReserveTicketRespVO> list) {
        if ( list == null ) {
            return null;
        }

        List<ReserveTicketExcelVO> list1 = new ArrayList<ReserveTicketExcelVO>( list.size() );
        for ( ReserveTicketRespVO reserveTicketRespVO : list ) {
            list1.add( reserveTicketRespVOToReserveTicketExcelVO( reserveTicketRespVO ) );
        }

        return list1;
    }

    public static ReserveTicketExcelVO reserveTicketRespVOToReserveTicketExcelVO(ReserveTicketRespVO reserveTicketRespVO) {
        if ( reserveTicketRespVO == null ) {
            return null;
        }

        ReserveTicketExcelVO reserveTicketExcelVO = new ReserveTicketExcelVO();

//        reserveTicketExcelVO.setId( reserveTicketRespVO.getId() );
//        reserveTicketExcelVO.setUserId( reserveTicketRespVO.getUserId() );
//        reserveTicketExcelVO.setCustomerType(CustomerTypeEnum.getNameByValue(reserveTicketRespVO.getCustomerType()) );
        reserveTicketExcelVO.setCustomerName( reserveTicketRespVO.getCustomerName() );
        if ( reserveTicketRespVO.getCustomerGender() != null ) {
            reserveTicketExcelVO.setCustomerGender(SexEnum.getNameByCode(Integer.parseInt(reserveTicketRespVO.getCustomerGender())));
        }
        reserveTicketExcelVO.setMobile( reserveTicketRespVO.getMobile() );
        reserveTicketExcelVO.setCustomerOrigin(CustomeSourceEnum.getNameByValue(reserveTicketRespVO.getCustomerOrigin()) );
//        reserveTicketExcelVO.setUrgencyLevel(UrgencyLevelEnum.getNameByValue(reserveTicketRespVO.getUrgencyLevel()) );
        if ( reserveTicketRespVO.getCheckInDate() != null ) {
            reserveTicketExcelVO.setCheckInDate(LocalDateTimeUtil.format(reserveTicketRespVO.getCheckInDate(), "yyyy-MM-dd"));
        }
        if ( reserveTicketRespVO.getReserveDate() != null ) {
            reserveTicketExcelVO.setReserveDate(LocalDateTimeUtil.format(reserveTicketRespVO.getReserveDate(), "yyyy-MM-dd"));
        }
        reserveTicketExcelVO.setReserveTimeStart( reserveTicketRespVO.getReserveTimeStart() );
        reserveTicketExcelVO.setReserveTimeEnd( reserveTicketRespVO.getReserveTimeEnd() );
        reserveTicketExcelVO.setRentTerm( reserveTicketRespVO.getRentTerm() );
//        reserveTicketExcelVO.setPriceMin( reserveTicketRespVO.getPriceMin() );
//        reserveTicketExcelVO.setPriceMax( reserveTicketRespVO.getPriceMax() );
        reserveTicketExcelVO.setAddress( reserveTicketRespVO.getAddress() );
        reserveTicketExcelVO.setPeopleNum( reserveTicketRespVO.getPeopleNum() );
//        reserveTicketExcelVO.setRentNum( reserveTicketRespVO.getRentNum() );
        reserveTicketExcelVO.setHouseType( reserveTicketRespVO.getHouseType() );
        reserveTicketExcelVO.setCreateTime( reserveTicketRespVO.getCreateTime() );
        reserveTicketExcelVO.setFollowUpUserName( reserveTicketRespVO.getFollowUpUserName());
        reserveTicketExcelVO.setFrom( reserveTicketRespVO.getTicketFrom());

        return reserveTicketExcelVO;
    }
}
